// vue.config.js
const { defineConfig } = require('@vue/cli-service')
const path = require('path')

const cdn = {
  js: [
    'https://cdn.jsdelivr.net/npm/echarts@5.4.2/dist/echarts.min.js',
    'https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js'
  ]
}
const isProd = process.env.NODE_ENV === 'production'

module.exports = defineConfig({
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src/')
      }
    },
    externals: isProd ? { echarts: 'echarts', xlsx: 'XLSX' } : {}
  },
  chainWebpack (config) {
    config.plugin('html').tap(args => {
      // 携带指定的属性到 html 模板中
      args[0].cdn = cdn
      return args
    })
  }

})
